States and Errors
How States and Errors are treated
The figure below shows how states and errors are treated.
StateChange (state manager)
Activates the new state required by M1_ReqState
StateName (state macro)
init state |
- Initializes exceptions on new state M1_CmdState <> M1_ReqState and on errors set in M1_StatusWord - Goes to exit state when an exception occurs - Performs all actions to properly enter this state (init variables, pipes, ...) - Sends commands to the submitted axis modules by setting Ai_CmdState to StateName and waits for their acknowledgement in Ai_AckState - Acknowledges end of initialization by setting M1_AckState to M1_ReqState |
run state |
- Waits for any function calls, activate function if called |
exit state |
- Performs all actions to properly leave this state - Acknowledges running by setting M1_AckState to 'busy' - If error stop occurs, activates STATE_ErrStop, otherwise sets new requested state M1_ReqState to M1_CmdState and activates StateChange |
How to add a new state
To add a new state, do as follows:
- copy a similar existing state sequence
- replace the old state name by the new one (e.g. 'Standby' by 'MyState')
- modify both init and exit sections of the new state to perform the relevant actions
- insert the needed function calls into the states run part
- add the state call command line into the state change sequence
- add the state definition values to the general declaration